﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using SponsorshipManager.DatabaseLayer;


namespace SponsorshipManager.DatabaseLayerConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            string ConnectionString = "Data Source=127.0.0.1;Initial Catalog=SponsorshipManager;User Id=appuser;Password=appuser;";
            Database DB = new Database(Database.DatabaseTypeEnum.dbSqlServer, ConnectionString);
            DB.Connection = true;
            Console.WriteLine("Connected {0}", DB.Connection.ToString());
            StoredProcedure sp = DB.StoredProcedure();
            sp.Name = "uspAuthenticate";
            sp.AddParameter("Username", DbType.String, "nick");
            sp.AddParameter("Password", DbType.String, "brandwood");
            sp.AddParameter("UserId", DbType.Int32);
            sp.AddParameter("Token", DbType.String);

            int ret = sp.ExecuteNoQuery();
            int UserId = (int)sp.GetParameter("UserId").Value;
            if (ret == 1)
            {
                string Token = sp.GetParameter("Token").Value.ToString();
                Console.WriteLine("User {0}, Token {1}",UserId.ToString(),Token);
            }

            Console.WriteLine("Hit enter to exit.");
            Console.ReadLine();

        }
    }
}
